package com.adamtron.blobup;

import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.LinkedList;

import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.blobstore.*;

/**
 * Serve a blob, given the blobKey
 * 
 * @author adam
 *
 */
@SuppressWarnings("serial")
public class BlobServeServlet extends HttpServlet {
    private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    
    public void doPost(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {
        
        String blobKey = (String)req.getParameter("bk");
        BlobKey key = new BlobKey(blobKey);
        
        blobstoreService.serve(key, res);
    }
}